package com.banfan.almond.web;

import com.banfan.almond.web.config.CreateDatabase;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;


@SpringBootApplication
@ComponentScan({
        "com.banfan.almond.utils",
        "com.banfan.almond.web.controller",
        "com.banfan.almond.web.service",
        "com.banfan.almond.web.config",
        "com.banfan.almond.web.security",
        "com.banfan.almond.web.annotation",
//        "com.banfan.almond.web.listener",
})
public class WebApplication {

    public static void main(String[] args) {

        String host = "localhost";

        if (args.length>0){
            host=args[0];
        }

        String sqlFilePath="static/almond_blog.sql";
        String port="3306";
        String username= "root";
        String password="root";
        String dataBaseName="almond_blog";
        try {
            CreateDatabase.executeSql(
                    sqlFilePath,
                    host,
                    port,
                    username,
                    password,
                    dataBaseName
            );

        } catch (Exception e) {
            e.printStackTrace();
        }

        SpringApplication.run(WebApplication.class, args);
    }

}
